//
//  CColorPickerViewController.m
//  IconMaster
//
//  Created by 为为 on 13-6-12.
//  Copyright (c) 2013年 为为. All rights reserved.
//

#import "CColorPickerViewController.h"

@interface CColorPickerViewController ()
 
// @property (weak, nonatomic) IBOutlet HRColorPickerView *colorPickView;
@property (nonatomic, weak) IBOutlet HRColorPickerView *colorPickerView;

@end


@implementation CColorPickerViewController

@synthesize colorPickerView = colorPickerView_;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization

    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
//    self.colorPickView.backgroundColor = [UIColor redColor];
    self.view.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
//    [colorPickerView_.brightnessSlider becomeFirstResponder];
//    [colorPickerView_ setNeedsFocusUpdate];
    [colorPickerView_ addTarget:self action:@selector(colorDidChanged:) forControlEvents:UIControlEventValueChanged];
    
//	colorPickerView = [[RSColorPickerView alloc] initWithFrame:colorPickerViewPlaceholder.frame];
//    colorPickerView.autoresizingMask = colorPickerViewPlaceholder.autoresizingMask;
//	colorPickerView.delegate = self;
//	[colorPickerView setBrightness:1.0];
//	[colorPickerView setCropToCircle:YES];
//	[colorPickerView setBackgroundColor:[UIColor clearColor]];
//	[self.view addSubview:colorPickerView];
//	colorPickerViewPlaceholder.hidden = true;
//	
//	brightnessSlider = [[RSBrightnessSlider alloc] initWithFrame:brightnessSliderPlaceHolder.frame];
//    brightnessSlider.autoresizingMask = brightnessSliderPlaceHolder.autoresizingMask;
//	[brightnessSlider setColorPicker:colorPickerView];
//	[brightnessSlider setUseCustomSlider:YES];
//	[self.view addSubview:brightnessSlider];
//	brightnessSliderPlaceHolder.hidden = true;
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidUnload {
    colorPickerView_ = nil;
//	colorPickerViewPlaceholder = nil;
//	brightnessSliderPlaceHolder = nil;
	[super viewDidUnload];
}


#pragma mark picker view delegate

-(void)colorPickerDidChangeSelection:(RSColorPickerView *)cp {
	if (self.colorChangedBlock) {
		self.colorChangedBlock(self, [cp selectionColor]);
	}
}
// 
- (void)colorDidChanged:(HRColorPickerView *)pickerView {
    
    if (self.colorChangedBlock) {
        self.colorChangedBlock(self, pickerView.color);
    }
//    [[[UIApplication sharedApplication] keyWindow] setTintColor:pickerView.color];
}

@end
